<!--
 * @Author: 吴竹叶 2107206923@qq.com
 * @Date: 2023-10-17 10:48:24
 * @LastEditors: 吴竹叶 2107206923@qq.com
 * @LastEditTime: 2023-11-07 16:13:43
 * @FilePath: \BZ_JT_AnQuanHuanBaoGuanLiApp\src\views\staging\carbon\emissionData\components\reportingManager.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="loadingbottom ">
    <div v-for="(item, index) in descListMap" :key="index">
      <customTitle v-if="item.label" :is-line="true" bg-color="#3795ff" :title="item.label" />
      <div v-for="(it, ind) in item.value" :key="ind" else>
        <custom-details-item :icon="it.icon" :label="it.label" :value="it.value">
          <template #valueSlot>

            <!-- <el-link v-if="it.label === '附件'" type="primary" @click="handleDownLoad(it.uuid)">{{ it.value }}</el-link> -->
            <el-link
              v-if="it.label === '附件'"
              type="primary"
              @click="openAttachPopUp([{
                'fileId': '',
                'fileName': it.value||'暂无数据',
                'fileUrl': it.uuid,
                'fileUuid': ''
              }])"
            >查看</el-link>
            <template v-else-if="it.label === '第三方附件'">
              <el-link type="primary" @click="openAttachPopUp(it.uuid)">查看</el-link>
              <!-- <div v-for="(file,inds) in it.uuid" :key="file.fileUuid + inds" style="width: 100%;">
                <el-link type="primary" class="desContent c-text-primary" @click="handleDownLoad(file.fileUrl)">{{ file.fileName }}</el-link>
              </div> -->
            </template>

            <span v-else>{{ it.value || '/' }}</span>
          </template>
        </custom-details-item>
      </div>
    </div>
    <attachPopUp ref="attachPopUp" />
  </div>
</template>

<script>
import { tpfReportManageView } from '@/api/carbon'
import commonList from '@/assets/mixin/commonList'
export default {
  mixins: [commonList],
  data() {
    return {
      descList: [],
      descListMap: [
        {
          label: '基本信息',
          value: [
            { field: 'companyName', label: '企业名称', value: '', icon: '' },
            { field: 'industry', label: '行业类别', value: '', icon: '' },
            { field: 'reportName', label: '报告名称', value: '', icon: '' },
            // { field: 'year', label: '年份', value: '', icon: '' },
            { field: 'compileTime', label: '编制时间', value: '', icon: '' },
            { field: 'reportTime', label: '上传时间', value: '', icon: '' },
            { isFile: true, field: 'attachmentsName', label: '附件', value: '', icon: '' }
          ]
        },
        {
          label: '第三方核查',
          value: [
            { field: 'isThirdpartCheck', label: '是否开展第三方核查', value: '', icon: '' },
            { field: 'thirdpartIdReportName', label: '第三方核查报告名称', value: '', icon: '' },
            { field: 'thirdpartPassTime', label: '核查通过时间', value: '', icon: '' },
            { field: 'thirdpartInstitutionName', label: '第三方检查机构名称', value: '', icon: '' },
            { field: 'thirdpartYear', label: '报告年度', value: '', icon: '' },
            { field: 'thirdpartReportTime', label: '上传时间', value: '', icon: '' },
            { isFile: true, field: 'shareAttachVos', label: '附件', value: '', icon: '' }
          ]
        }
      ]
    }
  },
  mounted() {
    const { current, id } = this.$route.query
    this.current = current
    this.id = id
    this.tpfReportManageView()
  },
  methods: {
    async tpfReportManageView() {
      this.layout.showAreaLoading(['.loadingbottom '])
      const { status, data } = await tpfReportManageView({ id: this.id })
      if (status === 0 && data) {
        this.descListMap.forEach((desc) => {
          desc.value.forEach((v) => {
            v.value = data[v.field] ? data[v.field] + '' : v.value
            if (v.isFile) {
              v.uuid = data[v.field.replaceAll('Name', 'Uuid')]
            }
          })
        })
      }
      this.layout.hideAreaLoading(['.loadingbottom '])
    }
  }
}
</script>
